package com.hackvan2012.controllers;
import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hackvan2012.datastore.AppDatastore;
import com.hackvan2012.datastore.dao.FoodEntryObject;
import com.hackvan2012.datastore.factory.DataFactory;


public class PostEntryController extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String imgURL = req.getParameter("imgURL");
		String dishName = req.getParameter("dishName");
		String restaurant = req.getParameter("restaurant");
		String title = req.getParameter("title");
		String description = req.getParameter("description");
		
		FoodEntryObject newFood = DataFactory.createFoodEntry(imgURL, dishName, restaurant, title, description);
		AppDatastore ds = new AppDatastore();
		ds.addFoodEntry(newFood);
		
		resp.sendRedirect("/viewentry?entryId="+newFood.getEntryID());
	}
}